package com.bajie.bjlisten.sevice;

import com.bajie.bjlisten.entity.BjCategory;
import com.bajie.bjlisten.entity.category_user.BjCategoryUserDto;
import com.bajie.bjlisten.entity.BjUserInterest;
import com.bajie.bjlisten.mapper.BjCategoryMapper;
import com.bajie.bjlisten.utils.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;

@Service
public class BjCategoryService {



        @Autowired
        BjCategoryMapper bjCategoryMapper;

    /**
     *根据Id查询分类表详情
     * @param Id
     * @return
     */
    public BjCategory getById(String Id){
        if (StringUtils.isNotEmpty(Id)){
            return bjCategoryMapper.getById(Id);
        }
        return  null;
    }


    /**
     * 查询随机分类
     * @param limit
     * @return
     */
    public   Set<BjCategory> selectRandomCategory(Integer limit){
            return bjCategoryMapper.selectRandomCategory(limit);

        }

    /**
     * app传参分类Id集合,查询所有分类
     * @param bjCategorys_list
     * @return
     */
    public Set<BjCategory> findListBjCategory(Set<String> bjCategorys_list){
            return bjCategoryMapper.findListBjCategory(bjCategorys_list);

        }



    /**
     * 两表查询用户喜欢的分类，包含分类名称和分类主键
     * @param userId
     * @param offset
     * @param limit
     * @return
     */
    public Set<BjCategory> findUserInterestBjCategoryName(String userId, Integer offset, Integer limit){
        return bjCategoryMapper.findUserInterestBjCategoryName(userId, offset, limit);
    }


    /**
     * 单表分页查询用户喜欢的分类，只包含分类主键
     * @param userId
     * @param offset
     * @param limit
     * @return
     */
    public Set<String> findListUserInterestBjCategoryName(String userId,Integer offset,
                                                          Integer limit){
        return bjCategoryMapper.findListUserInterestBjCategoryName(userId, offset, limit);
    }


        /**
         * 单表分页查询用户喜欢的分类，只包含分类主键、用户Id
         *
         * @param userId
         * @param offset
         * @param limit
         * @return
         */

        public List<BjUserInterest> findListUserInterest(String userId, Integer offset,
            Integer limit) {
        List<BjUserInterest> list = bjCategoryMapper.findListUserInterest(userId, offset, limit);
        return list;
    }

    /**
     * 根据分页参数查询分页数量
     * @param userId
     * @return
     */
    public Integer count(String userId){
           return bjCategoryMapper.count(userId);
    }



        /**
         * 两表查询用户喜欢的分类，包含分类名称和分类主键和用户ID
         *
         * @param userId
         * @param offset
         * @param limit
         * @return
         */

        public Set<BjCategoryUserDto> findListUser_Interest(String userId, Integer offset, Integer limit) {
        return bjCategoryMapper.findListUser_Interest(userId, offset, limit);

    }



}
